package com.demo.steammanagement.enums;

import lombok.Data;

public enum UserRoleEnum {
    ADMIN("1", "管理员"),
    USER("2", "用户"),
    COMMON_MEMBER("3", "普通会员"),
    VIP_MEMBER("4", "高级会员");

    private final String code;
    private final String description;

    UserRoleEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    // 根据code获取对应的枚举值
    public static UserRoleEnum fromCode(String code) {
        for (UserRoleEnum role : UserRoleEnum.values()) {
            if (role.getCode().equals(code)) {
                return role;
            }
        }
        throw new IllegalArgumentException("Unknown user role code: " + code);
    }
}